import axios from 'axios';
import type { AxiosRequestConfig,HeadersDefaults} from 'axios';
const request = axios.create({
  baseURL: '/',
});
 
interface myConfig extends AxiosRequestConfig {
  headers?: any
}


request.interceptors.request.use((config: myConfig) => {
  config.headers['Authorization'] = 'Bearer '+localStorage.getItem('token');
  return config;
});

request.interceptors.response.use(
  function (res) {
    // console.log(res);
    // return Promise.resolve(res);
    return res;
  },
  function (err) {
    // console.log(err);
    // return Promise.reject(err)
    return err;
  },
);

export default request;
